set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_BUILD_TYPE "debug")

set(ARM_TOOLS "C:/JL/pi32/bin")
# set(CMAKE_FIND_ROOT_PATH "C:/JL/pi32/pi32v2-include;C:/JL/pi32/pi32v2-lib/r3-large")
# set(CMAKE_SYSROOT "C:/JL/pi32/pi32v2-include;C:/JL/pi32/pi32v2-lib/r3-large")

set(CMAKE_C_COMPILER "${ARM_TOOLS}/clang.exe")
set(CMAKE_CXX_COMPILER "${ARM_TOOLS}/clang.exe")
set(CMAKE_AR "${ARM_TOOLS}/llvm-ar.exe")
set(CMAKE_LINKER "${ARM_TOOLS}pi32v2-lto-wrapper.exe")
set(CMAKE_AR_FLAGS "rs" CACHE STRING "Flags for ar" FORCE)
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> ${CMAKE_AR_FLAGS} <TARGET> <OBJECTS>")
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> ${CMAKE_AR_FLAGS} <TARGET> <OBJECTS>")

set(CMAKE_C_FLAGS_INIT "-target pi32v2 -mcpu=r3 -integrated-as -flto -Wuninitialized -Wno-invalid-noreturn -fno-common -integrated-as -Oz -g -flto -fallow-pointer-null -fprefer-gnu-section -Wno-shift-negative-value -Wundef -Wframe-larger-than=256 -Wincompatible-pointer-types -Wreturn-type -Wimplicit-function-declaration -mllvm -pi32v2-large-program=true -fms-extensions -fdiscrete-bitfield-abi -w")
set(CMAKE_CXX_FLAGS_INIT "-target pi32v2 -mcpu=r3 -integrated-as -flto -Wuninitialized -Wno-invalid-noreturn -fno-common -integrated-as -Oz -g -flto -fallow-pointer-null -fprefer-gnu-section -Wno-shift-negative-value -Wundef -Wframe-larger-than=256 -Wincompatible-pointer-types -Wreturn-type -Wimplicit-function-declaration -mllvm -pi32v2-large-program=true -fms-extensions -fdiscrete-bitfield-abi -w")

set(CMAKE_STATIC_LIBRARY_SUFFIX_C ".a")
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

option(USING_EXTERNAL_OPUS "using external opus lib" OFF)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)

